package com.example.phonestore.controller;

import com.example.phonestore.entity.Product;
import com.example.phonestore.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;

    @RequestMapping("/showHotProduct")
    public List<Product> showHotProduct(){
        List<Product> data=productService.showHotProduct();
        return data;
    }

    @RequestMapping("{id}/ProductOne")
    public Product ProductOne(@PathVariable("id") Integer id){
        Product data=productService.getProductOne(id);
        return data;
    }
}
